/*
 * @Description: 自定义参数对话框
 * @Author: gn
 * @Date: 2023-12-12 20:02:13
 * @LastEditors: 15801208559 1593215788@qq.com
 * @LastEditTime: 2023-12-13 23:24:24
 */

import React, { useState, forwardRef, useImperativeHandle } from 'react';
import { Button, Modal } from 'antd';
import TableEle from './tableEle';

/**
 * 对话弹出框结构
 */
const ModalEle = forwardRef((props, ref) => {

  const [loading, setLoading] = useState(false);
  const [open, setOpen] = useState(false);

  const {onClick} = props

  useImperativeHandle(
    ref,
    () => {
      return {
        openModal,
      };
    },
    []
  );

  const handleSubmit = i => {
    onClick()
    setOpen(false);
    // setLoading(true);
    // setTimeout(() => {
    //   setLoading(false);
    //   setOpen(false);
    // }, 3000);
  };

 const handleReset = () => {
  }

  const openModal = _ => {
    setOpen(true);
  };

  const handleCancel = () => {
    setOpen(false);
  };

  return (
    <div {...props} className="ModalEle">
      <Modal
        key="Modal"
        open={open}
        title="自定义模板参数"
        onCancel={handleCancel}
        footer={[
          <Button key="close" onClick={handleCancel}>
            关闭
          </Button>,
          <Button key="reset" danger type="primary" onClick={handleReset} loading={loading}>
            重置
          </Button>,
          <Button key="submit" type="primary" loading={loading} onClick={handleSubmit}>
            提交
          </Button>,
        ]}
      >
        <TableEle  />
      </Modal>
    </div>
  );
});

export default ModalEle;
